﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
using DCDataContext;
using DCEntities;
using System.Collections.ObjectModel;

namespace DataChannel.Web
{
    

    [ServiceContract(Namespace = "DataChannel")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class SqlData 
    {
        
        [OperationContract]
        public void DoWork()
        {
            // 在此处添加操作实现
            return;
        }
        // 在此处添加更多操作并使用 [OperationContract] 标记它们
        [OperationContract]
        public bool Login(string id, string password)
        {
            SqlService ins = SqlService.GetInstance("");
            
            //var query = from p in dcContext.DC_User
            //            where p.ID == id
            //            where p.Password == password
            //            select p;
            //if(query.Any())
            //    return true;

            return false ;

        }

        [OperationContract]
        public DC_User GetUserById(string id)
        {
            try
            {
                DC_User user=dcContext.DC_User.First(p => p.ID == id);
                return user;
            }
            catch (Exception e)
            {

                return null;
            }
        }

        [OperationContract]
        public Collection<user_valid_tasks> GetTasksByUserID(string id)
        {
            var query = from p in dcContext.user_valid_tasks
                        where p.user_id == id
                        orderby p.create_time
                        select p;
                        
            return new Collection<user_valid_tasks>(query.ToList());
        }


        
    }
}
